import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { maintenanceTaskVO, maintenanceTaskForm, maintenanceTaskQuery } from '@/api/maintenance/maintenance-task/types';

/**
 * 查询维保任务列表
 * @param query
 * @returns {*}
 */

export const listmaintenanceTask = (query?: maintenanceTaskQuery): AxiosPromise<maintenanceTaskVO[]> => {
  return request({
    url: '/maintenance/maintenance-task/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询维保任务详细
 * @param equipmentMaintenanceTaskId
 */
export const getmaintenanceTask = (equipmentMaintenanceTaskId: string | number): AxiosPromise<maintenanceTaskVO> => {
  return request({
    url: '/maintenance/maintenance-task/' + equipmentMaintenanceTaskId,
    method: 'get'
  });
};

/**
 * 新增维保任务
 * @param data
 */
export const addmaintenanceTask = (data: maintenanceTaskForm) => {
  return request({
    url: '/maintenance/maintenance-task',
    method: 'post',
    data: data
  });
};

/**
 * 修改维保任务
 * @param data
 */
export const updatemaintenanceTask = (data: maintenanceTaskForm) => {
  return request({
    url: '/maintenance/maintenance-task',
    method: 'put',
    data: data
  });
};

/**
 * 删除维保任务
 * @param equipmentMaintenanceTaskId
 */
export const delmaintenanceTask = (equipmentMaintenanceTaskId: string | number | Array<string | number>) => {
  return request({
    url: '/maintenance/maintenance-task/' + equipmentMaintenanceTaskId,
    method: 'delete'
  });
};
